{extend name="index/base" /}
{block name="main"}
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
<form class="layui-form" action="{:url('update')}" method="post">
    <input type="hidden" name="id" value="{$info.id}"/>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加信息</legend>
    </fieldset>

    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" id="title" value="{$info.title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属分类</label>
        <div class="layui-input-block">
            <select id="type_id" name="type_id" lay-verify="required">
                <option value="">请选择</option>
                {:tree_to_select($category_list)}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目关键字</label>
        <div class="layui-input-block">
            <input type="text" name="keyword" id="keyword" value="{$info.keyword}" required  lay-verify="required" placeholder="栏目关键字" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目描述</label>
        <div class="layui-input-block">
            <textarea name="description" id="description" placeholder="栏目描述" class="layui-textarea">{$info.description}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">栏目图片</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="test1">上传图片</button>
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="upload_pic" width="100px" src="{$info.pic}">
                    <input type="hidden" name="pic" id="pic" value="{$info.pic}">
                    <p id="demoText"></p>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">详细内容</label>
        <div class="layui-input-block">
            <script id="editor_content" type="text/plain"  name="content">{$info.goodscontent.content|stripslashes|raw}</script>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


    {load href="/static/js/jquery-1.10.2.min.js"/}
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;
        });
    </script>


    <script>
        layui.use('upload', function(){
            var upload = layui.upload;
            //执行实例
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                ,url: "{:url('File/upload')}" //上传接口
                ,done: function(res){
                    //上传完毕回调
                    layer.msg(res.msg);
                    $('#upload_pic').attr('src',res.data);
                    $('#pic').val(res.data);
                }
                ,error: function(){
                    //请求异常回调
                }
            });
        });
    </script>
    <script type="text/javascript">
        //实例化编辑器
        var ue = UE.getEditor('editor_content',{initialFrameWidth:'100%',initialFrameHeight:550});

        //设定分类选择
        $("#type_id option").each(function() {
	        if($(this).val()=='{$info.type_id}'){
				$(this).prop('selected',true);
	        }
	    });
    </script>
{/block}